<?php

/**
 * Created by PhpStorm.
 * User: WhiteBlue
 * Date: 15/3/3
 * Time: 下午7:00
 */
class database
{
    private function getConnection()
    {
        $con = mysql_connect(sql_url, sql_name, sql_pw);
        if ((!$con) && (!mysql_set_charset("utf8", $con)) && (!mysql_select_db(sql_database, $con))) {
            die('MySQl连接异常: ' . mysql_error());
        }
        return $con;
    }

    public function query($sql)
    {
        $con = $this->getConnection();
        $r = mysql_query($sql, $con);
        mysql_close($con);
        return $r;
    }

    public function queryBack($sql)
    {
        $con = $this->getConnection();
        $back = mysql_fetch_array($sql, $con);
        mysql_close($con);
        return $back;
    }

}